package gui;



import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

import java.awt.Font;
import javax.swing.JMenu;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import javax.swing.JMenuItem;
import java.awt.event.ActionEvent;
import java.awt.Rectangle;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.UIManager.LookAndFeelInfo;



public class Home extends JFrame {

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JMenuBar barraDeMenu = null;
	private JMenu produto = null;
	private JMenuItem item1 = null;
	private JMenuItem item2 = null;
	private JMenuItem item3 = null;
	private JMenu ficha = null;
	private JMenu operacional = null;
	private JMenuItem item4 = null;
	private JMenu cor = null;
	private JMenuItem m2item1 = null;
	private JMenuItem m2item2 = null;
	private JMenuItem m2item3 = null;
	private JLabel back = null;
	private JMenu operacoes = null;
	private JMenuItem m3item1 = null;
	private JMenuItem m3item2 = null;
	private JMenu maquinas = null;
	private JMenuItem m4item1 = null;
	private JMenuItem m4item2 = null;
	private JMenuItem m4item3 = null;
	private JMenuItem m3item3 = null;
    private JMenu menuInsumos = null;
	private JMenuItem itemMenuInsumos = null;
	private LookAndFeelInfo[] aparencia = null;
	/**
	 * This is the default constructor
	 */
	public Home() {
		super();
		aparencia = UIManager.getInstalledLookAndFeels();
		try {
			UIManager.setLookAndFeel(aparencia[1].getClassName());
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (UnsupportedLookAndFeelException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(1100, 760);
		back = new JLabel();
		back.setIcon(new ImageIcon(getClass().getResource("/imagensGui/Sig Textil 8.jpg")));
		back.setBounds(new Rectangle(312, 87, 543, 543));
		back.setText("");
		this.setResizable(false);
		this.setBackground(Color.black);
	//	this.setExtendedState(NORMAL);
		this.setJMenuBar(getBarraDeMenu());		
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setFont(new Font("Tahoma", Font.BOLD, 12));
		this.setContentPane(getJContentPane());
		this.setTitle("Sig Confex");
		this.setVisible(true);
		this.setExtendedState(MAXIMIZED_BOTH);
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.setBackground(new Color(238, 238, 238));
			jContentPane.add(back, null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes barraDeMenu	
	 * 	
	 * @return javax.swing.JMenuBar	
	 */
	private JMenuBar getBarraDeMenu() {
		if (barraDeMenu == null) {
			barraDeMenu = new JMenuBar();
			barraDeMenu.add(getProduto());
			barraDeMenu.add(getCor());
			barraDeMenu.add(getOperacoes());
			barraDeMenu.add(getJMenu());
            barraDeMenu.add(getMenuInsumos());
		}
		return barraDeMenu;
	}

	/**
	 * This method initializes produto	
	 * 	
	 * @return javax.swing.JMenu	
	 */
	private JMenu getProduto() {
		if (produto == null) {
			produto = new JMenu();
			produto.setText("Produto");
			produto.setMnemonic(KeyEvent.VK_P);
			produto.add(getItem1());
			produto.add(getItem2());
			produto.add(getItem3());
			produto.addSeparator();
			produto.add(getFicha());

		}
		return produto;
	}

	/**
	 * This method initializes item1	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getItem1() {
		if (item1 == null) {
			item1 = new JMenuItem();
			item1.setText("Cadastrar");
			item1.setMnemonic(KeyEvent.VK_A);
			item1.addActionListener(new ActionListener(){
				public void actionPerformed(java.awt.event.ActionEvent e) {
					CadastroDeProduto telaModal = new CadastroDeProduto(null);
					telaModal.setVisible( true );
					
				}
			
			});
		}
		return item1;
	}

	/**
	 * This method initializes item2	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getItem2() {
		if (item2 == null) {
			item2 = new JMenuItem();
			item2.setText("Editar/Remover");
			item2.setMnemonic(KeyEvent.VK_E);
			item2.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					EditaRemoveProduto telaModal = new EditaRemoveProduto(null);
					telaModal.setVisible( true );
				}
			});
		}
		return item2;
	}

	/**
	 * This method initializes item3	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getItem3() {
		if (item3 == null) {
			item3 = new JMenuItem();
			item3.setText("Listar");
			item3.setMnemonic(KeyEvent.VK_N);
			item3.addActionListener(new java.awt.event.ActionListener() {   
				public void actionPerformed(java.awt.event.ActionEvent e) {    
					ListarProdutos modal = new ListarProdutos(null);
					modal.setVisible(true);
				}
			
			});
		}
		return item3;
	}

	/**
	 * This method initializes ficha	
	 * 	
	 * @return javax.swing.JMenu	
	 */
	private JMenu getFicha() {
		if (ficha == null) {
			ficha = new JMenu();
			ficha.setEnabled(true);
			ficha.setText("Ficha T�cnica");
			ficha.add(getOperacional());
		}
		return ficha;
	}

	/**
	 * This method initializes operacional	
	 * 	
	 * @return javax.swing.JMenu	
	 */
	private JMenu getOperacional() {
		if (operacional == null) {
			operacional = new JMenu();
			operacional.setText("Operacional");
			operacional.setMnemonic(KeyEvent.VK_O);
			operacional.add(getItem4());
		}
		return operacional;
	}

	/**
	 * This method initializes item4	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getItem4() {
		if (item4 == null) {
			item4 = new JMenuItem();
			item4.setText("Cadastrar");
			item4.setMnemonic(KeyEvent.VK_A);
			item4.addActionListener(new ActionListener(){
				public void actionPerformed(java.awt.event.ActionEvent e) {
					CadastroDeFTO1 telaModal = new CadastroDeFTO1(null);					
					telaModal.setVisible( true );		
				}
			
			} );
		}
		return item4;
	}

	/**
	 * This method initializes cor	
	 * 	
	 * @return javax.swing.JMenu	
	 */
	private JMenu getCor() {
		if (cor == null) {
			cor = new JMenu();
			cor.setText("Cor");
			cor.setMnemonic(KeyEvent.VK_C);
			cor.add(getM2item1());
			cor.add(getM2item2());
			cor.add(getM2item3());
		}
		return cor;
	}

	/**
	 * This method initializes m2item1	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getM2item1() {
		if (m2item1 == null) {
			m2item1 = new JMenuItem();
			m2item1.setMnemonic(KeyEvent.VK_A);
			m2item1.setText("Cadastrar");
			m2item1.addActionListener(new ActionListener(){
				public void actionPerformed(java.awt.event.ActionEvent e) {
					CadastroDeCor telaModal = new CadastroDeCor(null);
					telaModal.setVisible(true);
					}
			
			});
		}
		return m2item1;
	}

	/**
	 * This method initializes m2item2	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getM2item2() {
		if (m2item2 == null) {
			m2item2 = new JMenuItem();
			m2item2.setText("Editar/Remover");
			m2item2.setMnemonic(KeyEvent.VK_N);
			m2item2.addActionListener(new ActionListener(){
				public void actionPerformed(ActionEvent e){
					EditarRemoverCores telaModal = new EditarRemoverCores(null);
					telaModal.setVisible( true );
				}
			});
		}
		return m2item2;
	}

	/**
	 * This method initializes m2item3	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getM2item3() {
		if (m2item3 == null) {
			m2item3 = new JMenuItem();
			m2item3.setMnemonic(KeyEvent.VK_N);
			m2item3.setText("Listar Cores");
			m2item3.addActionListener(new ActionListener(){

				@Override
				public void actionPerformed(ActionEvent arg0) {
					// TODO Auto-generated method stub
					ListarCores telamodal =new ListarCores(null);
					telamodal.setVisible(true);
				}
				
			});
		}
		return m2item3;
	}

	/**
	 * This method initializes operacoes	
	 * 	
	 * @return javax.swing.JMenu	
	 */
	private JMenu getOperacoes() {
		if (operacoes == null) {
			operacoes = new JMenu();
			operacoes.setText("Opera��es");
			operacoes.setMnemonic(KeyEvent.VK_O);
			operacoes.add(getM3item1());
			operacoes.add(getM3item2());
			operacoes.add(getM3item3());
		}
		return operacoes;
	}

	/**
	 * This method initializes m3item1	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getM3item1() {
		if (m3item1 == null) {
			m3item1 = new JMenuItem();
			m3item1.setMnemonic(KeyEvent.VK_A);
			m3item1.setText("Cadastrar");
			m3item1.addActionListener(new ActionListener(){
				public void actionPerformed(java.awt.event.ActionEvent e) {
					CadastroDeOperacoes telaModal = new CadastroDeOperacoes(null);
					telaModal.setVisible( true );					
				}
			
			});
		}
		return m3item1;
	}

	/**
	 * This method initializes m3item2	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getM3item2() {
		if (m3item2 == null) {
			m3item2 = new JMenuItem();
			m3item2.setMnemonic(KeyEvent.VK_E);
			m3item2.setText("Editar/Remover");
			m3item2.addActionListener(new ActionListener(){
				public void actionPerformed(ActionEvent e){
					EditarRemoverOperacoes telaModal = new EditarRemoverOperacoes(null);
					telaModal.setVisible( true );
				}
			});

			
		}
		return m3item2;
	}

	/**
	 * This method initializes jJMenuBar	
	 * 	
	 * @return javax.swing.JMenuBar	
	 */
	private JMenu getJMenu() {
		if (maquinas == null) {
			maquinas = new JMenu();
			maquinas.setMnemonic(KeyEvent.VK_M);
			maquinas.setText("M�quinas");
			maquinas.add(getM4item1());
			maquinas.add(getM4item2());
			maquinas.add(getM4item3());
		}
		return maquinas;
	}

	/**
	 * This method initializes m4item1	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getM4item1() {
		if (m4item1 == null) {
			m4item1 = new JMenuItem();
			m4item1.setMnemonic(KeyEvent.VK_C);
			m4item1.setText("Cadastrar");
			m4item1.addActionListener(new ActionListener(){
				public void actionPerformed(java.awt.event.ActionEvent e) {
					CadastroDeMaquinas telaModal = new CadastroDeMaquinas(null);
					telaModal.setVisible(true);
					}
			
			});
		}
		return m4item1;
	}

	/**
	 * This method initializes m4item2	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getM4item2() {
		if (m4item2 == null) {
			m4item2 = new JMenuItem();
			m4item2.setMnemonic(KeyEvent.VK_E);
			m4item2.setText("Editar/Remover");
			m4item2.addActionListener(new ActionListener(){
				public void actionPerformed(java.awt.event.ActionEvent e) {
					EditarRemoverMaquinas telaModal = new EditarRemoverMaquinas(null);
					telaModal.setVisible(true);
					}
			
			});
		}
		return m4item2;
	}

	/**
	 * This method initializes m4item3	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getM4item3() {
		if (m4item3 == null) {
			m4item3 = new JMenuItem();
			m4item3.setMnemonic(KeyEvent.VK_N);
			m4item3.setText("Listar");
			m4item3.addActionListener(new ActionListener(){
				public void actionPerformed(java.awt.event.ActionEvent e) {
					ListarMaquinas telaModal = new ListarMaquinas(null);
					telaModal.setVisible(true);
					}
			
			});
		
		}
		return m4item3;
	}

	/**
	 * This method initializes m3item3	
	 * 	
	 * @return javax.swing.JMenuItem	
	 */
	private JMenuItem getM3item3() {
		if (m3item3 == null) {
			m3item3 = new JMenuItem();
			m3item3.setText("Listar");
			m3item3.addActionListener(new ActionListener(){
				public void actionPerformed(java.awt.event.ActionEvent e) {
					ListarOperacoes telaModal = new ListarOperacoes(null);
					telaModal.setVisible(true);
					}
			
			});
		
			
		}
		return m3item3;
	}
	
    private JMenuItem getMenuInsumos() {

        if (menuInsumos == null) {

            menuInsumos = new JMenu();
            menuInsumos.setText("Insumos");
            menuInsumos.setMnemonic(KeyEvent.VK_I);
            menuInsumos.add(getItemMenuInsumos());

        }

        return menuInsumos;

    }
    

    private JMenuItem getItemMenuInsumos(){

        if(itemMenuInsumos == null) {

            itemMenuInsumos = new JMenuItem();
            itemMenuInsumos.setText("Insumos e Relacionados");
            itemMenuInsumos.setMnemonic(KeyEvent.VK_R);
            itemMenuInsumos.addActionListener(new ActionListener() {

                    @Override public void actionPerformed(ActionEvent event){

                        DialogoDeInsumos dialogo = new DialogoDeInsumos(null);
                        dialogo.setVisible(true);

                    }

                }

            );

        }

        return itemMenuInsumos;

    }


}  //  @jve:decl-index=0:visual-constraint="1,-30"
